function DigAddMoney takes nothing returns nothing
	local timer digTimer = GetExpiredTimer()
	local integer timerId = GetHandleId(digTimer)
	local unit digger = LoadUnitHandle(udg_HT , timerId , 3)
	local player diggerOwner = GetOwningPlayer(digger)
	//--
	call AddGoldWithTextTag(diggerOwner , (GetPlayerTechCount(diggerOwner , 'R001' , true) + 1) * 5 , digger)
	call SetUnitAnimationByIndex(digger , 62)
	//--
	set digTimer = null
	set digger = null
endfunction

function DigStart takes nothing returns nothing
	local unit digger = GetTriggerUnit()
	local timer getMoneyTimer = CreateTimer()
	local integer timerId = GetHandleId(getMoneyTimer)
	//--
	//該部隊的挖掘timer
	call SaveTimerHandle(udg_UnitDataHashTable , GetHandleId(digger) , StringHash("DIG_TIMER") , getMoneyTimer)
	
	call SaveUnitHandle(udg_HT , timerId , 3 , digger)
	call TimerStart(getMoneyTimer , 1.5 , true , function DigAddMoney)
	//--
	set digger = null
	set getMoneyTimer = null
endfunction

function DigStop takes nothing returns nothing
	local unit diggerToStop = GetTriggerUnit()
	local timer getMoneyTimer = LoadTimerHandle(udg_UnitDataHashTable , GetHandleId(diggerToStop) , StringHash("DIG_TIMER"))
	//--
	call PauseTimer(getMoneyTimer)
	call FlushChildHashtable(udg_HT , GetHandleId(getMoneyTimer))
	call DestroyTimer(getMoneyTimer)
	call RemoveSavedHandle(udg_UnitDataHashTable , GetHandleId(diggerToStop) , StringHash("DIG_TIMER"))
	//--
	set diggerToStop = null
	set getMoneyTimer = null
endfunction

function Trig_Dig_Conditions takes nothing returns boolean
	return GetSpellAbilityId() == 'A00L'
endfunction

function InitTrig_Dig takes nothing returns nothing
	local trigger startDig = CreateTrigger()
	local trigger stopDig = CreateTrigger()
	//--
	call TriggerRegisterAnyUnitEventBJ(startDig , EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(startDig , Condition(function Trig_Dig_Conditions))
	call TriggerAddAction(startDig , function DigStart)
	
	call TriggerRegisterAnyUnitEventBJ(stopDig , EVENT_PLAYER_UNIT_SPELL_ENDCAST )
	call TriggerAddCondition(stopDig , Condition(function Trig_Dig_Conditions))
	call TriggerAddAction(stopDig , function DigStop)
endfunction